import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
import About from '../views/About.vue'
import Login from '../views/Login.vue'
Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'Home',
    component: Home
  },
  {
    path: '/about',
    name: 'About',
    component: About
  },
  {
    path: '/login',
    name: 'Login',
    component: Login
  },
  {
    path: '/show',
    name: 'Show',
    component: resolve => require(['../views/Show.vue'], resolve)
  },
  {
    path:'/info',
    name:'Info',
    component: resolve => require(['../views/Info.vue'], resolve),
    children: [
      {
        path: 'userinfo',
        component: resolve => require(['../components/mycard.vue'], resolve),
      },
      {
        path: 'issue',
        component: resolve => require(['../components/issue.vue'], resolve),
      }
    ],
  },
  {
    path: '/showartic',
    name: 'Artic',
    component: resolve => require(['../views/Artic.vue'], resolve)
  }
]

const router = new VueRouter({
  routes
})
// router.beforeEach( (to,from,next) => {
//  if(to.path==='/'||to.path==='/login'){
//     next()
//  }else{
//    if(localStorage.getItem('token')==null){
//       alert('请先登录')
//       next('/login')
//    }
//    next();
//  }
  
// })

export default router
